<?php
namespace Home\Controller;

class MessageController extends BaseController {

    public function index(){
        $type = I('type');
        $key = I('key');

        if($type == 'news'){
            $posts = D('Posts')->where(['id'=>$key])->find();
        }elseif($type == 'help'){
            $posts = D('Helps')->where(['id'=>$key])->find();
        }elseif($type == 'cloud'){
            $posts = D('Cloud')->where(['id'=>$key])->find();
        }elseif($type == 'info'){
            $posts = D('Info')->where(['id'=>$key])->find();
        }

        $this->assign($posts);
        $this->display();
    }

    public function details(){
        $type = I('type');
        $key = I('key');

        if($type == 'news'){
            $posts = D('Posts')->where(['id'=>$key])->find();
        }elseif($type == 'help'){
            $posts = D('Helps')->where(['id'=>$key])->find();
        }elseif($type == 'cloud'){
            $posts = D('Cloud')->where(['id'=>$key])->find();
        }elseif($type == 'info'){
            $posts = D('Info')->where(['id'=>$key])->find();
        }

        $this->assign($posts);
        $this->display('index');
    }
}